package com.loovee.imaohu.wxapi;

import wxapi.WeiXin;
import android.app.Activity;
import android.os.Bundle;

import com.alstudio.module.sns.base.SnsConfig;
import com.alstudio.module.sns.weiboshare.IWeiboShare;
import com.alstudio.utils.log.ALLog;
import com.tencent.mm.sdk.openapi.BaseReq;
import com.tencent.mm.sdk.openapi.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
	private IWXAPI api;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		api = WXAPIFactory.createWXAPI(this, SnsConfig.WEIXIN_APP_ID, false);
		api.handleIntent(getIntent(), this);
		ALLog.d("微信分享");
	}

	@Override
	public void onReq(BaseReq arg0) {

	}

	@Override
	public void onResp(BaseResp resp) {
		int result = 0;

		switch (resp.errCode) {
		case BaseResp.ErrCode.ERR_OK:
			// MyToastUtil.getInstance().showToastOnCenter(
			// getString(R.string.string_get_share_success));
			if (WeiXin.callback != null) {
				WeiXin.callback.onSuccess(IWeiboShare.ACTION_SHARE);
			}
			break;
		// case BaseResp.ErrCode.ERR_USER_CANCEL:
		// result = R.string.errcode_cancel;
		// break;
		// case BaseResp.ErrCode.ERR_AUTH_DENIED:
		// result = R.string.errcode_deny;
		// break;
		default:
			// MyToastUtil.getInstance().showToastOnCenter(
			// getString(R.string.string_share_fail));
			break;
		}

		// TODO 微信分享 成功之后调用接口
		this.finish();
	}

}